﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace DbSharp.Framework.Assertion.Xml
{
    class XElmtRecordEqualityComparer : IEqualityComparer<XElement>
    {
        #region IEqualityComparer<XElement> Members

        public bool Equals(XElement x, XElement y)
        {
            if ((x == null) && (y == null))
                return true;
            else if ((x != null) && (y != null))
                return string.Equals(x.ToString(), y.ToString(), StringComparison.Ordinal);
            else
                return false;
        }

        public int GetHashCode(XElement obj)
        {
            if (obj == null)
                return 0;
            else
                return obj.ToString().GetHashCode();
        }

        #endregion
    }


    class XElmtRecordComparer : IComparer<XElement>
    {
        #region IComparer<XElement> Members

        public int Compare(XElement x, XElement y)
        {
            if ((x == null) && (y == null))
                return 0;
            else if ((x != null) && (y != null))
                return string.Compare(x.ToString(), y.ToString(), StringComparison.Ordinal);
            else
                return -1;
        }

        #endregion
    }
}
